package cn.tedu.collection;

import java.util.LinkedList;

public class TestLinkedList {
    public static void main(String[] args) {
        LinkedList<String> list=new LinkedList<>();
        list.add("孙悟空");
        list.add("猪八戒");
        list.add("唐三藏");
        list.add("沙师弟");
        list.add("白龙马");
        System.out.println(list );
        list.addFirst("蜘蛛精");
        System.out.println(list);
        list.addLast("玉兔精");
        System.out.println(list);
        System.out.println(list.getFirst());
        System.out.println(list.getLast());

        System.out.println(list.removeFirst());
        System.out.println(list);
        System.out.println(list.removeLast());
        System.out.println(list);

        System.out.println(list.element());
        /*别名:查询系统*/
        System.out.println(list.getFirst());
        System.out.println(list.element());
        System.out.println(list.peek());
        System.out.println(list.peekFirst());

        System.out.println(list.peekLast());
        /*别名:新增系统*/
        System.out.println(list.offer("海绵宝宝"));//添加尾元素
        System.out.println(list);
        System.out.println(list.offerFirst("派大星"));
        System.out.println(list.offerLast("蟹老板"));
        System.out.println(list);

        /*别名:删除系列*/
        System.out.println(list.poll());//删除首元素
        System.out.println(list);
        System.out.println(list.peekFirst());
        System.out.println(list.peekLast());


    }
}
